$(document).ready(function() {
  require(["inputdrop", "asset"], function(inputdrop, asset) {
    var list_col = [
      { name: "", text: "", hideSearch: "hide", width: 3 },
      { text: "事件名称", name: "operator", align: "left", width: 15 },
      {
        text: "事件等级",
        name: "logType",
        align: "left",
        width: 15,
        searchRender: function(el) {
          el.append(
            '<input type="text" class="form-control input-sm" search-data="userName">'
          );
        }
      },
      { text: "设备品牌", name: "message", align: "left", width: 10 },
      { text: "设备型号", name: "message", align: "left", width: 10 },
      { text: "使用人", name: "message", align: "left", width: 10 },
      { text: "组织机构", name: "message", align: "left", width: 10 },
      {
        text: "发生时间",
        name: "time",
        align: "left",
        width: 15,
        render: function(text) {
          return text ? new Date(text).Format("yyyy-MM-dd hh:mm:ss") : "";
        }
      },
      {
        text: "上报时间",
        name: "time",
        align: "left",
        width: 15,
        render: function(text) {
          return text ? new Date(text).Format("yyyy-MM-dd hh:mm:ss") : "";
        }
      }
    ];

    terminal_event_list({ paramObj: null, isLoad: true, maskObj: "body" });
    index_search_div_remove_click(terminal_event_list, {
      paramObj: null,
      isLoad: true,
      maskObj: "body"
    });

    function terminal_event_list(option) {
      g_grid.render($("#table_div"), {
        header: list_col,
        url: "api/public/syslog/pmmc",
        type: "xd",
        dataKey: "list",
        hasBorder: false,
        hideSearch: true,
        paramObj: option.paramObj,
        isLoad: option.isLoad,
        maskObj: option.maskObj,
        autoHeight: true,
        showCount: true,
        allowCheckBox: false
      });
    }

 

    // 交互效果逻辑代码
    $("input[placeholder]").placeholder();
    laydate.render({
      elem: "#timeRange",
      range: true,
      max: 0,
      done: function(value, date, endDate) {
        console.log(value); //得到日期生成的值，如：2017-08-18
        var startTime = "",
          endTime = "";
        if (value) {
          var time = value.split(" - ");
          startTime = Date.parse(new Date(time[0]));
          endTime = Date.parse(new Date(time[1]));
        }
        g_grid.refresh($("#table_div"), {
          paramObj: {
            startTime: startTime,
            endTime: endTime
          }
        });
      }
    });
  });
});
